package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验和教训：
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2993 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2993.class.getResource("P2993.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		List<Piece> pieces = new ArrayList<Piece>();

		String line = stdin.readLine().trim();
		String[] white = line.substring("White: ".length()).trim().split(",");
		for (String p: white) {
			Piece piece = new Piece();
			if (p.length() == 3) {
				piece.type = p.charAt(0);
				piece.col = p.charAt(1);
				piece.row = p.charAt(2);
			} else {	//p
				piece.type = 'P';
				piece.col = p.charAt(0);
				piece.row = p.charAt(1);
			}
			pieces.add(piece);
		}
        
		line = stdin.readLine().trim();
		String[] black = line.substring("Black: ".length()).trim().split(",");
		for (String p: black) {
			Piece piece = new Piece();
			if (p.length() == 3) {
				piece.type = (char)(p.charAt(0)-'A'+'a');
				piece.col = p.charAt(1);
				piece.row = p.charAt(2);
			} else {	//p
				piece.type = 'p';
				piece.col = p.charAt(0);
				piece.row = p.charAt(1);
			}
			pieces.add(piece);
		}
		
        System.out.println(create(pieces));
	}
	
	private static String create(List<Piece> pieces) {
		
		char[][] board = new char[8][];
		for (int i = 0; i < 8; i ++) {
			board[i] = new char[8];
			for (int j = 0; j < 8; j ++) board[i][j] = ' ';
		}
		
		for (Piece piece: pieces) {
			board[8-(piece.row-'0')][piece.col-'a'] = piece.type;
		}
		
		//create string format of chess board
		String strBoard = "";
		for (int i = 0; i < 8; i ++) {
			strBoard += "+---+---+---+---+---+---+---+---+\n";
			String line = "|";
			for (int j = 0; j < 8; j ++) {
				if ((i-j)%2 == 0) {	//...
					line += "." + ((board[i][j]==' ')?".":board[i][j]) + "." + "|";
				} else {	//:::
					line += ":" + ((board[i][j]==' ')?":":board[i][j]) + ":" + "|";
				}
			}
			strBoard += line + "\n";
		}
		strBoard += "+---+---+---+---+---+---+---+---+";
		return strBoard;
	}

	private static class Piece {
		
		char type;
		char col;
		char row;
	}
}
